package com.adobe.util
{
	import com.adobe.serialization.json.*;
	import com.adobe.coreUI.controls.whiteboardClasses.*;
	import mx.controls.Alert;
	
	public class ObjectUtil
	{
		public function ObjectUtil()
		{
			
		}
		public static function obj_json_encoder1(obj:Object):String{
			var jsonEn:JSONEncoder = new JSONEncoder(obj);
			var jsonStr:String = jsonEn.getString();
		//	trace("encoder:"+jsonStr);
			return jsonStr;
		}
		
		public static function obj_json_decoder1(jsonStr:String):Object{
		//	trace("decoder:"+jsonStr);
			//Alert.show(jsonStr,"decoder");
			var jsonDe:JSONDecoder = new JSONDecoder(jsonStr);
			var obj2:Object = jsonDe.getValue();//反序列化
			return obj2;
		}
		
		public static function obj_json_encoder2(obj:WBShapeDescriptor):String{
			var jsonEn:JSONEncoder = new JSONEncoder(obj);
			var jsonStr:String = jsonEn.getString();
	//		trace("encoder:"+jsonStr);
			return jsonStr;
		}
		
		public static function obj_json_decoder2(jsonStr:String):WBShapeDescriptor{
		//	trace("decoder:"+jsonStr);
			var jsonDe:JSONDecoder = new JSONDecoder(jsonStr);
			var obj2:WBShapeDescriptor = (WBShapeDescriptor)(jsonDe.getValue());//反序列化
			//trace(obj2.name,obj2.sex);
			return obj2;
		}		
	}
	

}